package com.vilen.basic.util;

import java.sql.*;

/**
 * Created by vilen on 2015/8/24.
 */
public class DbUtil {
    public static Connection getConnection() throws SQLException {
        Connection con = null;
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/cms_test","root","123");
        return con;
    }

    public static void close (Connection con) {
        try {
            if(con!=null) {
                con.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void close (PreparedStatement ps) {
        try {
            if(ps!=null) {
                ps.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    public static void close(ResultSet rs) {
        try{
            if(rs!=null){
                rs.close();
            }
        }catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
